package com.tamartech.greendb.ui.views;



import org.springframework.richclient.table.support.AbstractObjectTable;

import com.tamartech.greendb.dao.ElectoralRollEntryDAO;
import com.tamartech.greendb.ui.dialogs.AbstractPropertiesDialog;
import com.tamartech.greendb.ui.tables.RollEntryTable;

public class RollEntryView extends AbstractTableView
{
    /** The object table holding our contacts. */
    RollEntryTable rollEntryTable;

    public RollEntryView()
    {
        super ("rollEntryView");
    }
    
    public void setRollEntryTable(RollEntryTable rollEntryTable)
    {
        this.rollEntryTable = rollEntryTable;
    }

    // ?? why not set in spring config?
    protected ElectoralRollEntryDAO getRollEntryDAO()
    {
        return (ElectoralRollEntryDAO) getApplicationContext().getBean("electoralRollEntryDAO");
    }

    @Override
    protected AbstractPropertiesDialog getEditObjectDialog()
    {
        // We know exactly one contact will be selected at this time because
        // of the guards put in place in prepareTable.
        return new RollEntryPropertiesDialog(rollEntryTable.getSelectedRollEntry(),
                                           getRollEntryDAO());
    }

    @Override
    protected String[] getFilterProperties()
    {
        return new String[] {"reference"};
    }

    @Override
    protected AbstractObjectTable getObjectTable()
    {
        return rollEntryTable;
    }
}
